<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="${pageContext.request.contextPath}/media/layui/css/layui.css" media="all">
<script src="${pageContext.request.contextPath}/media/js/jquery.min.js"></script>
</head>
<body>
<form class="layui-form" id="sousuo"
			action="${pageContext.request.contextPath}/student/show?pageindex=1" method="post">
<div class="layui-container">
    <div class="layui-row" style="margin-top: 10px">
        <div class="layui-col-xs3" style="margin-right: 20px">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">姓名：</label>
                <div class="layui-input-block">
                    <input type="text" id="no" name="name" value="${pagebean.t.name}" class="layui-input" placeholder="学生姓名">
                </div>
            </div>
        </div>
        <div class="layui-col-xs3" style="margin-right: 20px">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">班级：</label>
                <div class="layui-input-block">
                    <select class="layui-input" id="fg" name="gid">
                    <option value="">请选择班级</option>
                       <c:forEach items="${gradelist}" var="g" varStatus="v">
                        <option value="${g.id}"${pagebean.t.gid==g.id?"selected":""}>${g.name}</option>
                        </c:forEach>
                       
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs2">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" type="submit" onclick="sh()"><i class="layui-icon layui-icon-search">搜索</i></button>
                </div>
            </div>
        </div>
       
        <div class="layui-col-xs2">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <a class="layui-btn layui-btn-mini layui-btn-mini" href="javascript:exportExcel()" lay-event="detail">导出Excel</a>
                </div>
            </div>
        </div>
    </div>
</div>
	 </form>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>学号</td>
					<td>姓名</td>
					<td>班级</td>
					<td>性别</td>
					<td>手机号</td>
					<td>邮箱</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${pagebean.lis}" var="s" varStatus="v">
				<tr>
					<td>${s.id}</td>
					<td>${s.name}</td>
					<td>${s.grade.name}</td>
					<td>${s.sex}</td>
					<td>${s.phone}</td>
					<td>${s.email}</td>
					<td><a class="layui-btn layui-btn-mini" href="${pageContext.request.contextPath}/student/update?sid=${s.id}">编辑</a>
						<a class="layui-btn layui-btn-mini layui-btn-mini" href="${pageContext.request.contextPath}/student/xiangxi?sid=${s.id}" lay-event="detail">查看详情</a>
						<a class="layui-btn layui-btn-danger layui-btn-mini"
						lay-event="del" onclick="deleteCourse(${s.id});">删除</a>
					</td>
				</tr>
				</c:forEach>
			</tbody>
		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1" style="float: right;">
						 	<a href="#" onclick="gopage(1);">首页</a>
				<c:if test="${pagebean.pagein!=1}">
				<a href="#" onclick="gopage(${pagebean.pagein-1});">上一页</a>
				</c:if>
				<c:forEach begin="${pagebean.start}" end="${pagebean.end}" step="1" var="i">
				<c:if test="${pagebean.pagein==i}">
				<a href="#" onclick="gopage(${i});" style="color: red;">${i}</a>
				</c:if>
				<c:if test="${pagebean.pagein!=i}">
				<a href="#" onclick="gopage(${i});">${i}</a>
				</c:if>
				</c:forEach>
				<c:if test="${pagebean.pagein!=pagebean.toalPage}">
				<a href="#" onclick="gopage(${pagebean.pagein+1});">下一页</a>
				</c:if>
				<a href="#" onclick="gopage(${pagebean.toalPage});">尾页</a>
				<span>
				[${pagebean.pagein}/${pagebean.toalPage}]页
				[${pagebean.count}]项
				</span>
						</div>
	</div>
	
	<script src="${pageContext.request.contextPath}/media/layui/layui.js"></script>
	
	<script type="text/javascript">
	   function deleteCourse(sid){
		   if(confirm("确定删除?")){
				location.href="${pageContext.request.contextPath}/student/del?sid="+sid;
				}
	   }
	   
	   function gopage(index) {
		   $("#sousuo").attr("action","${pageContext.request.contextPath}/student/show?pageindex="+(index==null?1:index))
			$("#sousuo").submit();
		}
	   
	  function sh() {
		  var s = $("[name=name]").val();
		  var m = $("[name=gid]").val();
		  var q = ${pagebean.end};
	}
	 
		layui.use([ 'form', 'laydate' ],
						function() {
							var form = layui.form, layer = layui.layer, laydate = layui.laydate;

		});

		
		
		//导入Excel
		function exportExcel(){
			$("#sousuo").attr("action","${pageContext.request.contextPath}/student/export");
			$("#sousuo").submit();
		}
	</script>
	
	
</body>
</html>